package com.ruoyi.swla2.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.swla2.domain.FileVideo;
import com.ruoyi.swla2.service.IFileVideoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 音频文件Controller
 *
 * @author gdqt
 * @date 2025-06-26
 */
@RestController
@RequestMapping("/swla2/fileVideo")
public class FileVideoController extends BaseController
{
    @Autowired
    private IFileVideoService fileVideoService;

    /**
     * 查询音频文件列表
     */
    @PreAuthorize("@ss.hasPermi('swla2:fileVideo:list')")
    @GetMapping("/list")
    public TableDataInfo list(FileVideo fileVideo)
    {
        startPage();
        List<FileVideo> list = fileVideoService.selectFileVideoList(fileVideo);
        return getDataTable(list);
    }

    /**
     * 导出音频文件列表
     */
    @PreAuthorize("@ss.hasPermi('swla2:fileVideo:export')")
    @Log(title = "音频文件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FileVideo fileVideo)
    {
        List<FileVideo> list = fileVideoService.selectFileVideoList(fileVideo);
        ExcelUtil<FileVideo> util = new ExcelUtil<FileVideo>(FileVideo.class);
        util.exportExcel(response, list, "音频文件数据");
    }

    /**
     * 获取音频文件详细信息
     */
    @PreAuthorize("@ss.hasPermi('swla2:fileVideo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fileVideoService.selectFileVideoById(id));
    }


    @GetMapping(value = "/getInfoExtendMore")
    public AjaxResult getInfoExtend(FileVideo fileVideo)
    {
        return success(fileVideoService.selectFileVideoByParams(fileVideo));
    }

    /**
     * 新增音频文件
     */
    @PreAuthorize("@ss.hasPermi('swla2:fileVideo:add')")
    @Log(title = "音频文件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FileVideo fileVideo)
    {
        return toAjax(fileVideoService.insertFileVideo(fileVideo));
    }

    /**
     * 修改音频文件
     */
    @PreAuthorize("@ss.hasPermi('swla2:fileVideo:edit')")
    @Log(title = "音频文件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FileVideo fileVideo)
    {
        return toAjax(fileVideoService.updateFileVideo(fileVideo));
    }

    /**
     * 删除音频文件
     */
    @PreAuthorize("@ss.hasPermi('swla2:fileVideo:remove')")
    @Log(title = "音频文件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fileVideoService.deleteFileVideoByIds(ids));
    }
}
